﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OnlineHelpDesk.BLL_Service;

namespace OnlineHelpDesk.Admin
{
    public partial class AdminProfile : System.Web.UI.Page
    {
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Service1 s = new Service1();
                String userName = Session["UserName"].ToString();
                En_Users eu = s.getUserbyName(userName);
                txtUserFullName.Text = eu.UserFullName;
                txtUserAge.Text = eu.UserAge.ToString();
                DropDownList1.SelectedValue = eu.UserGender;
                txtUserEmail.Text = eu.UserEmail;
                txtUserName.Text = eu.UserName;
                txtUserType.Text = s.getTypeNamebyTypeID(eu.TypeID);
            }
        }
  
        protected void btnChange_Click(object sender, EventArgs e)
        {
            txtUserFullName.ReadOnly = false;
            txtUserEmail.ReadOnly = false;
            txtUserAge.ReadOnly = false;
            DropDownList1.Enabled = true;
            btnSave.Enabled=true;
            btnChange.Enabled = false;
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            Service1 s = new Service1();
            String userName = Session["userName"].ToString();
            String UserFullName = txtUserFullName.Text;
            int UserAge = Convert.ToInt32(txtUserAge.Text);
            String UserGenger = DropDownList1.SelectedItem.Text.ToString();
            String UserEmail = txtUserEmail.Text;
            s.UpDateProfileUser(userName, UserFullName, UserAge, UserGenger, UserEmail);
            Response.Redirect("AdminProfile.aspx");

        }
       
    }
}